//
//  ZQTopicVideoView.m
//  BuDeJie
//
//  Created by 仲琦 on 16/4/15.
//  Copyright © 2016年 仲琦. All rights reserved.
//

#import "ZQTopicVideoView.h"
#import "ZQTopic.h"
#import "UIImageView+Download.h"
#import "ZQSeeBigPictureViewController.h"
@interface ZQTopicVideoView ()

@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UILabel *playVideoLabel;

@property (weak, nonatomic) IBOutlet UILabel *videoTimeLabel;

@end


@implementation ZQTopicVideoView

- (void)awakeFromNib
{
    self.autoresizingMask = UIViewAutoresizingNone;
    
    self.imageView.userInteractionEnabled = YES ;
  
    [self.imageView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(seeBigPicture)]];
    
    
}

- (void)seeBigPicture
{
    ZQSeeBigPictureViewController *seeBigPicture = [[ZQSeeBigPictureViewController alloc]init];
    seeBigPicture.topic = self.topic;
    [self.window.rootViewController presentViewController:seeBigPicture animated:YES completion:nil];
    
}

- (void)setTopic:(ZQTopic *)topic
{
    _topic = topic;
    
    UIImage *placeholderImage = nil;
    
    [self.imageView zq_setImageOriginalImageURL:topic.image1 thumbnailImageURL:topic.image0 placeholderImageURL:placeholderImage completed:nil];
    
    
    if (topic.playcount >= 10000) {
        self.playVideoLabel.text = [NSString stringWithFormat:@"%.2f万次播放", topic.playcount / 10000.0];
    }else{
        self.playVideoLabel.text = [NSString stringWithFormat:@"%zd次播放", topic.playcount];
    }
    
    self.videoTimeLabel.text = [NSString stringWithFormat:@" %zd : %zd", topic.videotime / 60, topic.videotime % 60];
    
    
}


@end
